//package ly.gupao.edu.spring;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.Enumeration;
//import java.util.HashMap;
//
///**
// * @author: liyang
// * @date：2018/6/1 0001
// * describe：全局异常处理
// */
//@ControllerAdvice
//@ResponseBody
//public class GloableExceptionHandler {
//
//    private Logger logger = LoggerFactory.getLogger(GloableExceptionHandler.class);
//
//
//    @ExceptionHandler(value = Exception.class)
//    public String jsonHandler(HttpServletRequest request, Exception e) throws Exception {
//        HashMap map = new HashMap();
//        map.put("捕获到异常:", e.getMessage());
//        log(e, request);
//        return map.toString();
//    }
//
//
//    private void log(Exception ex, HttpServletRequest request) {
//        logger.error("************************异常开始*******************************");
////        if(SystemSession.getAccount() != null)
////        logger.error("当前用户id是" + SystemSession.getAccount().getUid());
//        logger.error(String.valueOf(ex));
//        logger.error("请求地址：" + request.getRequestURL());
//        Enumeration enumeration = request.getParameterNames();
//        logger.error("请求参数");
//        while (enumeration.hasMoreElements()) {
//            String name = enumeration.nextElement().toString();
//            logger.error(name + "---" + request.getParameter(name));
//        }
//
//        StackTraceElement[] error = ex.getStackTrace();
//        for (StackTraceElement stackTraceElement : error) {
//            logger.error(stackTraceElement.toString());
//        }
//        logger.error("************************异常结束*******************************");
//    }
//
//}
